package com.jeesite.modules.task.dceconomicindicator.service;

import com.jeesite.common.collect.MapUtils;
import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.task.dceconomicindicator.dao.DcSupTaskScoreDao;
import com.jeesite.modules.task.dceconomicindicator.entity.DcSupTaskScore;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 任务扣分表Service
 * @author xhc
 * @version 2022-10-29
 */
@Service
@Transactional(readOnly=false)
public class DcSupTaskScoreService extends CrudService<DcSupTaskScoreDao, DcSupTaskScore> {
	
	/**
	 * 获取单条数据
	 * @param dcSupTaskScore
	 * @return
	 */
	@Override
	public DcSupTaskScore get(DcSupTaskScore dcSupTaskScore) {
		return super.get(dcSupTaskScore);
	}
	
	/**
	 * 查询分页数据
	 * @param dcSupTaskScore 查询条件
	 * @param dcSupTaskScore.page 分页对象
	 * @return
	 */
	@Override
	public Page<DcSupTaskScore> findPage(DcSupTaskScore dcSupTaskScore) {
		return super.findPage(dcSupTaskScore);
	}
	
	/**
	 * 查询列表数据
	 * @param dcSupTaskScore
	 * @return
	 */
	@Override
	public List<DcSupTaskScore> findList(DcSupTaskScore dcSupTaskScore) {
		return super.findList(dcSupTaskScore);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param dcSupTaskScore
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(DcSupTaskScore dcSupTaskScore) {
		super.save(dcSupTaskScore);
	}
	
	/**
	 * 更新状态
	 * @param dcSupTaskScore
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(DcSupTaskScore dcSupTaskScore) {
		super.updateStatus(dcSupTaskScore);
	}
	
	/**
	 * 删除数据
	 * @param dcSupTaskScore
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(DcSupTaskScore dcSupTaskScore) {
		super.delete(dcSupTaskScore);
	}

    public Page<Map<String, Object>> findPageDes(DcSupTaskScore dcSupTaskScore) {
		Page<Map<String, Object>> pageMap = new Page<>(dcSupTaskScore.getPageNo(), dcSupTaskScore.getPageSize());
		Map<String, Object> params = MapUtils.newHashMap();
		params.put("leaderOrgCode", dcSupTaskScore.getLeaderOrgCode());
		params.put("createUnit", dcSupTaskScore.getCreateUnit());
		params.put("taskYear", dcSupTaskScore.getTaskYear());
		params.put("orderBy", dcSupTaskScore.getOrderBy());
		params.put("page", pageMap); // 给 Map 设置 page 参数即可自动分页
		pageMap.setList(dao.findListForMap(params));
		System.out.println(pageMap.getList());	// 获取当前页数据
		System.out.println(pageMap.getCount());
		return pageMap;
    }

	public List<Map> queryCreateUnit() {
		return dao.queryCreateUnit();
	}
}